<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>用户页面</title>
	<link rel="shortcut icon" href="#" />
<link rel="stylesheet" th:href="@{/css/exam.css}">
<!-- <script src="js/exam.js" ></script> -->
</head>
<body>

	<!-- 最外层div -->
	<div>
		<!-- 上层显示栏 -->
		<div class="topLine">
			
			<div id="second" class="time">00</div>
			<div class="time" style="width: 10px;">:</div>
			<div id="minute" class="time">30</div>
			<div class="time" style="width: 100px;">剩余时间：</div>
		</div>
		<div style="width: 100vw;">
			<!-- 测试题目显示区域 -->
			<div class="subject">
				<div style="text-align: center;margin-top: 100px;">
					<div id="app" style="display: inline-block; margin-left: 50px;">
						<div class="box" id="box_minute">
							<div class="top child text" id="top">0</div>
							<div class="flip child" id="flip">
								<div class="flip_face child text" id="flip_face">0</div>
								<div class="flip_back child text" id="flip_back">0</div>
							</div>
							<div class="bottom child text" id="bottom">0</div>
						</div>
					</div>

					<div id="alg" style="display: inline-block; margin-left: 50px;">
						<div class="box" id="box_minute1">
							<div class="top child text" id="top1">+</div>
							<div class="flip child" id="flip1">
								<div class="flip_face child text" id="flip_face1">+</div>
								<div class="flip_back child text" id="flip_back1">+</div>
							</div>
							<div class="bottom child text" id="bottom1">+</div>
						</div>
					</div>

					<div id="adder2" style="display: inline-block;margin-left: 50px;">
						<div class="box" id="box_minute2">
							<div class="top child text" id="top2">0</div>
							<div class="flip child" id="flip2">
								<div class="flip_face child text" id="flip_face2">0</div>
								<div class="flip_back child text" id="flip_back2">0</div>
							</div>
							<div class="bottom child text" id="bottom2">0</div>
						</div>
					</div>
				</div>

				<div class="answer">
					你的答案：
					<input type="text" class="answerInput" id="answer">
				</div>
				<div class="changeBtn" id="change">下一题</div>
			</div>
			<!-- 答题卡区域 -->
			<div class="answerSheet">
				<div class="answerSheetTitle">
					答题卡
				</div>
				<!-- 题目显示区域 -->
				<div class="subjectNo" id="subjectNo">
<!--					<div class="sheetBlcok">-->
<!--						1-->
<!--					</div>-->
<!--					<div class="sheetBlcok" style="background-color: #850D04FF">2</div>-->
					
				</div>
			</div>
		</div>
		
	</div>

<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/userInfo.js}"></script>
<script th:inline="javascript">
    // 获取Dom
    const box_minute = document.querySelector("#box_minute");
    const Top = box_minute.querySelector("#top");
    const flip = box_minute.querySelector("#flip");
    const flipFace = flip.querySelector("#flip_face");
    const flipBack = flip.querySelector("#flip_back");
    const Bottom = box_minute.querySelector("#bottom");

    const box_minute1 = document.querySelector("#box_minute1");
    const Top1 = box_minute1.querySelector("#top1");
    const flip1 = box_minute1.querySelector("#flip1");
    const flipFace1 = flip1.querySelector("#flip_face1");
    const flipBack1 = flip1.querySelector("#flip_back1");
    const Bottom1 = box_minute1.querySelector("#bottom1");

    const box_minute2 = document.querySelector("#box_minute2");
    const Top2 = box_minute2.querySelector("#top2");
    const flip2 = box_minute2.querySelector("#flip2");
    const flipFace2 = flip2.querySelector("#flip_face2");
    const flipBack2 = flip2.querySelector("#flip_back2");
    const Bottom2 = box_minute2.querySelector("#bottom2");

    var userId = 1;//用户id
    var bit = [[${bit}]];//位数
    var modal = [[${modal}]];//测试类型
	var type = [[${type}]];//整数、实数、分数
    var timeStamp;//测试时间戳
    var minute;
    var second;
    var rightCount = 0;//答对的题数
    var maxRightCount = 3;//需要答对的题目数量
    const box = document.querySelector(".box")

	var allType = type+""+bit+""+modal
    let timer = null, timerTwo = null;
    var List = [];
    var oprator = ['+','-','x','/'];

	console.log("bit="+bit+" type="+type+" modal="+modal);


    // 生成二位算数列表
    if(bit == 2){
    	if(type == 1){//整数
			for (var i = 0; i <100; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*89+10);
				let adder2 = Math.floor(Math.random()*89+10);
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					if(adder1>adder2){
						result = adder1-adder2;
					}else{
						let temp = adder2;
						adder2 = adder1;
						adder1 = temp;
						result = adder1-adder2;
					}
				}else if (cul == 'x') {
					result = adder1*adder2;
				}else{
					adder1 = Math.floor(Math.random()*9+1);
					adder2 = Math.floor(Math.random()*11+1);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}
				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 2){//实数
			for (var i = 0; i <100; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*10+1)+Math.floor(Math.random()*10)*0.1;
				let adder2 = Math.floor(Math.random()*10+1)+Math.floor(Math.random()*10)*0.1;
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					if(adder1>adder2){
						result = adder1-adder2;
					}else{
						let temp = adder2;
						adder2 = adder1;
						adder1 = temp;
						result = adder1-adder2;
					}

				}else if (cul == 'x') {
					adder1 = Math.floor(Math.random()*10+1)+Math.floor(Math.random()*10)*0.1;
					adder2 = Math.floor(Math.random()*89+10);
					result = adder1*adder2;
				}else{
					adder1 = Math.floor(Math.random()*10+1)+Math.floor(Math.random()*10)*0.1;
					adder2 = Math.floor(Math.random()*89+10);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}
				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 3){
			$("div.child").css("width","300");
			$("#alg .child").css("width","130");
			$("div.child").css("font-size","80px");
			$("#alg .child").css("font-size","100px");
    		for(let i=0;i<100;i++){
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*9+1)*0.01;
				let adder11 = createFrc(adder1);
				let adder2 = Math.floor(Math.random()*9+1)*0.01;
				let adder22 = createFrc(adder2);
				let result;
				if(cul == "+"){
					result = adder2+adder1;
				}else if(cul == "-"){
					if(adder1>adder2){
						result = adder1-adder2;
					}else{
						let temp = adder2;
						adder2 = adder1;
						adder1 = temp;
						result = adder1-adder2;

						temp = adder11;
						adder11 = adder22;
						adder22 = adder11;
					}
				}else if(cul == "x"){
					result = adder1*adder2;
				}else if(cul == "/"){
					result = adder1/adder2;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder11,
					alg:cul,
					adder2:adder22,
					result:result
				}
				List.push(item);
			}
			console.log("finish");
		}
		Top.innerHTML = List[0].adder1;
    	// flip.innerHTML = List[0].adder1;
    	flipBack.innerHTML = List[0].adder1;
    	flipFace.innerHTML = List[0].adder1;
    	Bottom.innerHTML = List[0].adder1;

		Top1.innerHTML = List[0].alg;
		// flip1.innerHTML = List[0].alg;
		flipBack1.innerHTML = List[0].alg;
		flipFace1.innerHTML = List[0].alg;
		Bottom1.innerHTML = List[0].alg;

		Top2.innerHTML = List[0].adder2;
		// flip2.innerHTML = List[0].adder2;
		flipBack2.innerHTML = List[0].adder2;
		flipFace2.innerHTML = List[0].adder2;
		Bottom2.innerHTML = List[0].adder2;
    }
    

    //生成三位
    if(bit == 3){
    	if(type == 1){
			for (var i = 0; i <1000; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*899+100);
				let adder2 = Math.floor(Math.random()*899+100);
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					result = adder1-adder2;
				}else if (cul == 'x') {
					adder2 = Math.floor(Math.random()*99+1);
					result = adder1*adder2;
				}else{
					adder1 = Math.floor(Math.random()*89+10);
					adder2 = Math.floor(Math.random()*10+1);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 2){//实数
			for (var i = 0; i <1000; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*89+10)+Math.floor(Math.random()*10)*0.1;
				let adder2 = Math.floor(Math.random()*89+10)+Math.floor(Math.random()*10)*0.1;
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					result = adder1-adder2;
				}else if (cul == 'x') {
					adder2 = Math.floor(Math.random()*99+1);
					result = adder1*adder2;
				}else{
					adder2 = Math.floor(Math.random()*10+1);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 3){
			$("div.child").css("width","300");
			$("#alg .child").css("width","130");
			$("div.child").css("font-size","80px");
			$("#alg .child").css("font-size","100px");
    		for(let i=0;i<100;i++){
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*9+1)*0.01;
				let adder11 = createFrc(adder1);
				let adder2 = Math.floor(Math.random()*9+1)*0.01;
				let adder22 = createFrc(adder2);
				let result;
				console.log("createOne");
				if(cul == "+"){
					result = adder2+adder1;
				}else if(cul == "-"){
					if(adder1>adder2){
						result = adder1-adder2;
					}else{
						let temp = adder2;
						adder2 = adder1;
						adder1 = temp;
						result = adder1-adder2;

						temp = adder11;
						adder11 = adder22;
						adder22 = adder11;
					}
				}else if(cul == "x"){
					result = adder1*adder2;
				}else if(cul == "/"){
					result = adder1/adder2;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder11,
					alg:cul,
					adder2:adder22,
					result:result
				}
				List.push(item);
				console.log("createOneFinish");
			}
			console.log("finishCreate");
		}
		Top.innerHTML = List[0].adder1;
		flip.innerHTML = List[0].adder1;
		flipBack.innerHTML = List[0].adder1;
		flipFace.innerHTML = List[0].adder1;
		Bottom.innerHTML = List[0].adder1;

		Top1.innerHTML = List[0].alg;
		flip1.innerHTML = List[0].alg;
		flipBack1.innerHTML = List[0].alg;
		flipFace1.innerHTML = List[0].alg;
		Bottom1.innerHTML = List[0].alg;

		Top2.innerHTML = List[0].adder2;
		flip2.innerHTML = List[0].adder2;
		flipBack2.innerHTML = List[0].adder2;
		flipFace2.innerHTML = List[0].adder2;
		Bottom2.innerHTML = List[0].adder2;
    }
    
	//生成四位
    if(bit == 4){
    	if(type == 1){
			for (var i = 0; i <1000; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*8999+1000);
				let adder2 = Math.floor(Math.random()*8999+1000);
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					result = adder1-adder2;
				}else if (cul == 'x') {
					adder2 = Math.floor(Math.random()*99+1);
					result = adder1*adder2;
				}else{
					adder1 = Math.floor(Math.random()*899+100);
					adder2 = Math.floor(Math.random()*10+1);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 2){
			for (var i = 0; i <1000; i++) {
				//确定运算符
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*899+100)+Math.floor(Math.random()*10)*0.1;
				let adder2 = Math.floor(Math.random()*899+100)+Math.floor(Math.random()*10)*0.1;
				let result;
				if(cul == '+'){
					result = adder1+adder2;
				}else if (cul == '-') {
					result = adder1-adder2;
				}else if (cul == 'x') {
					adder2 = Math.floor(Math.random()*99+1);
					result = adder1*adder2;
				}else{
					adder2 = Math.floor(Math.random()*10+1);
					let temp = adder2*adder1;
					result = adder1;
					adder1 = temp;
				}
				result = result.toFixed(8);
				let item = {
					adder1:adder1,
					alg:cul,
					adder2:adder2,
					result:result
				}
				List.push(item);
			}
		}else if(type == 3){
			$("div.child").css("width","300");
			$("#alg .child").css("width","130");
			$("div.child").css("font-size","80px");
			$("#alg .child").css("font-size","100px");
    		for(let i=0;i<100;i++){
				let cul = oprator[Math.floor((Math.random()*oprator.length))];
				let adder1 = Math.floor(Math.random()*9+1)*0.01;
				let adder11 = createFrc(adder1);
				let adder2 = Math.floor(Math.random()*9+1)*0.01;
				let adder22 = createFrc(adder2);
				let result;
				if(cul == "+"){
					result = adder2+adder1;
				}else if(cul == "-"){
					if(adder1>adder2){
						result = adder1-adder2;
					}else{
						let temp = adder2;
						adder2 = adder1;
						adder1 = temp;
						result = adder1-adder2;

						temp = adder11;
						adder11 = adder22;
						adder22 = adder11;
					}
				}else if(cul == "x"){
					result = adder1*adder2;
				}else if(cul == "/"){
					result = adder1/adder2;
				}

				result = result.toFixed(8);
				let item = {
					adder1:adder11,
					alg:cul,
					adder2:adder22,
					result:result
				}
				List.push(item);
			}

		}
		Top.innerHTML = List[0].adder1;
		flip.innerHTML = List[0].adder1;
		flipBack.innerHTML = List[0].adder1;
		flipFace.innerHTML = List[0].adder1;
		Bottom.innerHTML = List[0].adder1;

		Top1.innerHTML = List[0].alg;
		flip1.innerHTML = List[0].alg;
		flipBack1.innerHTML = List[0].alg;
		flipFace1.innerHTML = List[0].alg;
		Bottom1.innerHTML = List[0].alg;

		Top2.innerHTML = List[0].adder2;
		flip2.innerHTML = List[0].adder2;
		flipBack2.innerHTML = List[0].adder2;
		flipFace2.innerHTML = List[0].adder2;
		Bottom2.innerHTML = List[0].adder2;
    }
    

    const min = document.querySelector("#minute");
    const sec = document.querySelector("#second");

    const size = ()=>{
    	if (bit > 2) {
    		$("div.child").css("width","220");
    		$("#alg .child").css("width","130");
    	}
    	if(bit>3){
    		$("div.child").css("width","280");
    		$("#alg .child").css("width","130");
    	}
    }
    size();

    //类型1（固定时间，答对题目越多成绩越高）
    if(modal == 1){
    	//倒计时30分钟
	    const countdown = ()=>{
	    	minute = "00";
		    second = 5;

		    timerTwo = setInterval(function(){
		    	if(minute == "00" && second == "01"){
			    	clearInterval(timerTwo);
			    	alert("测试超时，强制交卷!");
			    	// setTimeout("alert('测试超时，强制交卷！')",3000);
			    	//发送请求
			    	$.ajax({
			    		url:"/uploadScore",
			    		data:{
			    			'userId':userId,
			    			'type':allType,
			    			'rightCount':rightCount,
			    			'timeStamp':1800000
			    		},
			    		type:"POST",
			    		dataType:"json",
			    		success:function(data){
			    			console.log("结果："+data);
			    			//跳转到首页
			    			// self.location = document.referrer;
							// window.location.href="userInfo.html";
							history.back(-1);
			    		}

			    	})
			    }else{
			    	second--;
		    		if(second == 00){
			    		second = 59;
			    		minute--;
			    		if(minute<10){
			    			minute = "0"+minute;
			    		};
			    	};
			    	if(second<10){
			    		second = "0"+second;
			    	}

			    	min.innerHTML = minute;
			    	sec.innerHTML = second;
			    	console.log("1");
			    	console.log(minute);
			    	console.log(second);
			    }
		    },1000);


	    }
	    countdown();
    }
    
    //类型2（固定题目数量，答对题目越多且用时越少成绩越高）
    else if(modal == 2){
    	//设置时间
    	var countTime = ()=>{
    		minute = "00";
    		second = "00";
    		timerTwo = setInterval(function(){
    			if(minute == "60"){
    				clearInterval(timerTwo);
    				setTimeout('alert("测试超时，强制交卷！")',3000);
    				$.ajax({
    					url:"/uploadScore",
			    		data:{
			    			'userId':userId,
			    			'type':allType,
			    			'rightCount':rightCount,
			    			'timeStamp':3600000
			    		},
			    		type:"POST",
			    		dataType:"json",
			    		success:function(data){
			    			console.log(data);
			    			//跳转到首页
			    			window.location.href="userInfo.html";
			    		}
    				})
    			}
    			else{
    				second++;
    				if(second == 59){
    					second = "00";
    					minute++;
    					if(minute<10){
    						minute = "0"+minute;
    					};
    					if(second<10){
    						second = "0"+second;
    					}

    					min.innerHTML = minute;
    					sec.innerHTML = second;
    					console.log("2");
    					console.log(minute);
    					console.log(second);
    				}
    			}

    		},1000);
    	}
    	countTime();
    }

    //类型3（固定需要答对题目的数量，用时越少分数越高）
    else if(modal == 3){
    	maxRightCount = 3;//需要答对的题目数量
    	//计时
    	let countTime = ()=>{
    		minute = "00";
    		second = 0;
    		timerTwo = setInterval(function(){
    			if(minute >= "60"){
    				clearInterval(timerTwo);
    				alert("测试超时，强制交卷！");
    				// setTimeout('alert("测试超时，强制交卷！")',3000);
    				$.ajax({
    					url:"/uploadScore",
			    		data:{
			    			'userId':userId,
			    			'type':allType,
			    			'rightCount':rightCount,
			    			'timeStamp':3600000
			    		},
			    		type:"POST",
			    		dataType:"json",
			    		success:function(data){
			    			console.log(data);
			    			//跳转到首页
			    			// window.location.href="userInfo.html";
							history.back(-1);
			    		}
    				})
    			}else{
    				second++;
    				if(second == 59){
    					second = 00;
    					minute++;
    					if(minute<10){
							minute = "0"+minute;
						};
    				}
    				
					if(second<10){
						second = "0"+second;
					}
    				min.innerHTML = minute;
					sec.innerHTML = second;
					console.log("3");
					console.log(minute);
					console.log(second);
    				console.log("end");
    			}
    		},1000)
    	}
    	countTime();
    }


    //题目刷新js
    const OneCycle = (n, timer) => { // 一次翻页的周期

      	let num = 0;
      	flipFace.style.zIndex = 1;
      	flipBack.style.zIndex = 0;
      	flip.style.transform = "perspective(500px) rotateX(0deg)"; // rotateX(0deg) => rotateX(-180deg)
      	flipFace.innerHTML = List[n].adder1;
      	Bottom.innerHTML = List[n].adder1;

	  	flipFace1.style.zIndex = 1;
      	flipBack1.style.zIndex = 0;
      	flip1.style.transform = "perspective(500px) rotateX(0deg)"; // rotateX(0deg) => rotateX(-180deg)
      	flipFace1.innerHTML = List[n].alg;
      	Bottom1.innerHTML = List[n].alg;

      	flipFace2.style.zIndex = 1;
      	flipBack2.style.zIndex = 0;
      	flip2.style.transform = "perspective(500px) rotateX(0deg)"; // rotateX(0deg) => rotateX(-180deg)
      	flipFace2.innerHTML = List[n].adder2;
      	Bottom2.innerHTML = List[n].adder2;

      	timer = setInterval(() => {
        num++;
        if (num > 50) {
          	clearInterval(timer);
          	return;
        };

        if (num === 1) {
          	Top.innerHTML = List[n+1].adder1; // 60 和 0 在时间里，其实是一样的
          	flipBack.innerHTML = List[n+1].adder1;

          	Top1.innerHTML = List[n+1].alg; // 60 和 0 在时间里，其实是一样的
          	flipBack1.innerHTML = List[n+1].alg;

          	Top2.innerHTML = List[n+1].adder2; // 60 和 0 在时间里，其实是一样的
          	flipBack2.innerHTML = List[n+1].adder2;
        }

        if (num <= 25) {
          	flipFace.style.zIndex = 1;
          	flipBack.style.zIndex = 0;

          	flipFace1.style.zIndex = 1;
          	flipBack1.style.zIndex = 0;

          	flipFace2.style.zIndex = 1;
          	flipBack2.style.zIndex = 0;
        } else {
			flipFace.style.zIndex = 0;
          	flipBack.style.zIndex = 1;

          	flipFace1.style.zIndex = 0;
          	flipBack1.style.zIndex = 1;

          	flipFace2.style.zIndex = 0;
          	flipBack2.style.zIndex = 1;
        }
        // console.log(num); // 1 ~ 50
        flip.style.transform = `perspective(500px) rotateX(-${180 * num / 50}deg)`

        flip1.style.transform = `perspective(500px) rotateX(-${180 * num / 50}deg)`

        flip2.style.transform = `perspective(500px) rotateX(-${180 * num / 50}deg)`

        
        console.log(List[n].adder1[0]);
      }, 20); // 将一秒钟分成50份。
    };

    //cycle();

    // 浏览器页面切换时，定时器setInterval抖动问题
    document.onvisibilitychange = function () {
      	if (document.visibilityState === "visible") {
        //cycle();
      	} else {
        	clearInterval(timer);
        	clearInterval(timerTwo);
      	}
    }

    //已经做过的题目的数量（list数组下标）
    var index = 0;
    //下一题按钮点击事件
    $("#change").click(function(){
		OneCycle(index,timer);
		console.log(document.getElementById("answer").value);
		console.log(List[index].result);
    	if ((document.getElementById("answer").value - List[index].result).toFixed(8) == (0).toFixed(8)) {//判断结果是否正确
    		rightCount++;
    		console.log("rightCount="+rightCount);
			document.getElementById('subjectNo').innerHTML+='<div class="sheetBlcok" style="background-color: darkolivegreen">'+(index+1)+'</div>';
    		index++;
			if(type == 2){
    			if(index == 19){
    				timeStamp = 1000*second+60000*minute;
    				console.log(timeStamp);
    				alert("测试完成，成绩提交完后跳转首页");
    				// setTimeout('alert("测试完成，成绩提交完后跳转首页！")',3000);
    				$.ajax({
    					url:"/uploadScore",
			    		data:{
			    			'userId':userId,
			    			'type':allType,
			    			'rightCount':rightCount,
			    			'timeStamp':timeStamp
			    		},
			    		type:"POST",
			    		dataType:"json",
			    		success:function(data){
			    			console.log(data);
			    			//跳转到首页
			    			// window.location.href="userInfo.html";
							history.back(-1);
			    		}

    				})
    			}
    		}
    		else if(type == 3){
    			if(rightCount == maxRightCount){
    				clearInterval(countTime);
    				timeStamp = 1000*second+60000*minute;
    				console.log(timeStamp);
    				alert("测试完成，成绩提交完后跳转首页！");
    				// setTimeout('alert("测试完成，成绩提交完后跳转首页！")',3000);
    				$.ajax({
    					url:"/uploadScore",
			    		data:{
			    			'userId':userId,
			    			'type':allType,
			    			'rightCount':rightCount,
			    			'timeStamp':timeStamp
			    		},
			    		type:"POST",
			    		dataType:"json",
			    		success:function(data){
			    			console.log(data);
			    			//跳转到首页
			    			// window.location.href="userInfo.html";
							history.back(-1);
			    		}
    				})
    			}
    		}


    	}else{
    		console.log("wrong answer! the right answer is "+List[index].result)
			document.getElementById('subjectNo').innerHTML+='<div class="sheetBlcok" style="background-color: #850D04FF">'+(index+1)+'</div>';
    		index++;
    	}

      	document.getElementById('answer').value = '';

    })


	function createFrc(frc) {
		let a = 1;
		let b = 1;
		while(frc!=a/b){
			if(frc>a/b){
				a++;
			}else{
				b++;
			}
		}
		console.log("frc")
		return a+"/"+b;
	}
  </script>

</body>
</html>